Originally, on the site of the future castle, there was a hillfort of the Livs tribe. Thanks to the chronicler Henry of Latvia, we know that its ruler was named Wjaczko and was dependent on Polotsk. He in 1207 agreed to become the vassal of bishop of Riga and gave away some of his possessions in exchange for protection and sending specialists to strengthen the fortifications of the hillfort. The contract did not last long, as a result of a conflict Wjaczko murdered Germans, burned fortifications and fled to Rus. Bishop Albert took control of the destroyed hillfort and in 1209 started building the stone castle Kokenhusen. Initially, the right to 1/3 of stronghold had the Order of Livonian Brothers of the Sword, but a few years later they gave it away for territorial assignments in other areas. The basic form of the castle was ready in 1225, so it was one of the oldest stone objects in Livonia.
A settlement was built near the castle, which quickly turned into a city and still in the 13th century it was fortified with stone defensive walls (brick town fortifications are mentioned in 1277). Both centers became the main administrative point of the Archbishopric of Riga over Daugava river, and the castle was one of its largest strongholds. In the thirteenth and fourteenth centuries, its administrators were mostly members of the powerful Livonian Tiesenhausen family, Kokenhusen also served as the residence of the archbishops.
From the fifteenth century, the castle has undergone numerous modifications, adapting it to conduct defense with the use of firearms. Nevertheless, in 1479, the stronghold was taken over by the Teutonic Order, which imprisoned archbishop Sylwester Stodewescher until the death. After the church authorities regained the castle in 1486, a similar fate met the last archbishop of Riga, Margrave of Brandenburg in 1556. This time the king of Poland, Zygmunt August, saved the hierarchy from captivity. In 1577 Kokenhusen was occupied by the troops of Ivan the Terrible, but they were quickly removed by Polish-Lithuanian troops. During the reign of Poland, the starosty was established at the castle. During the Polish-Swedish wars, Kokenhusen was occupied twice by the Swedes, in 1601 and 1608, but also then Polish troops recaptured the fortress. Eventually, the castle fell away from Poland in 1625 and remained under Sweden until the end of the century. All the time it kept a great military significance, enlarged by early modern modernizations of fortifications in the bastion system. In 1700, the Saxon and Polish troops of Augustus II occupied the castle and the city, but not seeing the possibility of effective defense against the approaching Swedes, left the stronghold and blew up its main elements. From then on, the castle remained in ruin, and the city depended on it was abandoned.
The basic plan of the castle, shaped already in the 13th century, gave it the appearance of a two-part defensive complex located on a high hill, whose natural protection from the south was the river Daugava, and from the north and west the Perse river. The plan of the upper castle exceptionally did not refer to the conventual architecture of the Teutonic Order, but rather to the Western European model. It had two wings separating a courtyard, widening towards the east, whose eastern wall was also built. Representation rooms probably were located on the first floor, in the north wing it was probably a refectory and closer to the west tower, the chapel. The ground floor in the northern wing was occupied by a brewery, bakery and kitchen, while in the south wing there was a mill driven by horses. The slightly smaller eastern building probably housed guard rooms and economic rooms.
The western side of the upper castle was ended by two cylindrical towers and one four-sided tower placed between them. The next four-sided towers were erected in the north-eastern and south-eastern corners. In addition, the two corner towers had an outer bailey and city walls. The town had urban fortifications combined with a castle, which protected it and at the same time dominated it.
Nowadays, the castle has been preserved in the form of a ruin, unfortunately without the destroyed main elements, which were its western towers. Contemporary surroundings, although picturesque, are completely ahistorical. Due to the construction of a dam on the Daugava river by the communist authorities, the water level has risen considerably, as a result of which the hill has disappeared, and the castle almost grows out of the water.
Borowski T, Miasta, zamki i klasztory, Inflanty, Warszawa 2010.